package com.ssi.dao.customer.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import com.ssi.dao.customer.ICustomerDao;
import com.ssi.entity.customer.Customer;

@Repository("customerDao")
public class CustomerDaoImpl implements ICustomerDao {

	@Autowired
	@Qualifier("sqlMapClientTemplate")
	SqlMapClientTemplate sqlMapClientTemplate;

	public Customer getUserById(int id) {
		Customer customer=(Customer) sqlMapClientTemplate.queryForObject("selectCustomerById", id);
		return customer;
	}
	
	public List<Customer> checkUser(Customer customer) {
		//sqlMapClientTemplate.insert("customerNameSpace.insertCustomer",customer);
		return sqlMapClientTemplate.queryForList("customerNameSpace.selectCustomerByClass", customer);
	}

	public Long insertCustomer(Customer customer) {
		return (Long)sqlMapClientTemplate.insert("customerNameSpace.insertCustomer",customer);
	}
	
	public List<Customer> queryCustomerListByUserName(String userName){
		return sqlMapClientTemplate.queryForList("customerNameSpace.queryCustomerListByUserName",userName);
	}

	public List<Customer> queryCustomerListByEmail(String userEmail) {
		return sqlMapClientTemplate.queryForList("customerNameSpace.queryCustomerListByEmail",userEmail);
	}
}
